package test.ej.chapter1.rule5;

import java.util.Arrays;

public class AvoidNew
{

	public static void main(String[] args)
	{
		new AvoidNew().launch();
	}

	/**
	 * debug to see valueOf and parseInt
	 * valueOf() return a Integer, and keep a Integer array to cache int between -128~127, otherwise new Integer
	 * parseInt() return a int
	 * however if the Left part of the assignment is a Integer Type(i2)
	 * , will still result in a new Integer procedure to finish autoboxing
	 */
	private void launch()
	{
		int[] a = { 1, 2, 3 };
		int b[] = { 2, 3, 4 };
		System.out.println(Arrays.toString(a));
//		Integer i1 = new Integer(-1);
		Integer i3 = Integer.valueOf("-1000");
		Integer i2 = Integer.parseInt("-1000");
		int i4 = Integer.parseInt("-1000");
//		Integer i4 = Integer.getInteger("-1");
		Integer i5 = Integer.valueOf("-1000");
		int i = 0;

		System.out.println();
		System.out.println(i2 == i);
		System.out.println(i2 == i3);
		System.out.println("important	" + (i2 == i5));
		System.out.println();
		System.out.println(i3 == i);
		System.out.println(i3 == i5);
	}
}
